package com.europe.business.europebusiness.ui.adapter;


import android.content.Context;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.ViewGroup;

import com.europe.business.europebusiness.ui.adapter.viewholder.ListViewHolder;



import java.util.List;

/**
 * 通用的多类型的adapter
 * @param <T>
 */
public  abstract  class MutilItemCommonAdapter<T> extends ListAdapter<T>{    MultiItemTypeSupport multiItemTypeSupport;
    public static final int VIWE_TYPE_FOOT = 1;
    public static final int VIWE_TYPE_DATA = 0;
    private int isHaveFoot;

    public MutilItemCommonAdapter(Context context, List<T> datas,  MultiItemTypeSupport multiItemTypeSupport, ItemClicked itemClicked) {
        super(context, datas, -1, itemClicked);
        this.multiItemTypeSupport = multiItemTypeSupport;
    }
    public int getDataCount(){
        return mDatas.size();
    }

    public void setIsHaveFoot(int isHavFoot){
        this.isHaveFoot=isHavFoot;
    }



    @Override
    public int getItemCount() {
        return mDatas.size()+isHaveFoot;
    }

    @Override
    public int getItemViewType(int position) {
        return multiItemTypeSupport.getItemViewType(position);
    }

    @NonNull
    @Override
    public ListViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        int layoutId = multiItemTypeSupport.getLayoutId(i);
        return  ListViewHolder.getViewHold(mContext, layoutId, viewGroup);
    }

/*    @Override
    public void onBindViewHolder(@NonNull ListViewHolder listViewHolder, int i) {
        if (i>=mDatas.size()){
            return;
        }else {
            super.onBindViewHolder(listViewHolder, i);

        }

    }*/
}
